home *** CD-ROM | disk | FTP | other *** search
/ PC go! 2008 April / PCgo 2008-04 (DVD).iso / interface / contents / demoversionen_3846 / 13664 / files / Data1.cab / turbocad_test2.vbs < prev    next >
Encoding:
Text File  |  2001-10-16  |  1.7 KB  |  80 lines

  1. 'Script to test for adding graphics to the drawing
  2.  
  3. Option Explicit
  4.  
  5. Dim TORADIANS
  6. Dim tcApp
  7.  
  8. '================= Add graphic the tail of collection
  9. Sub AddTail(tcGrs)
  10.  
  11. Dim tcGr
  12.     Set tcGr = tcGrs.AddArcCenterAndPoint(0, 0, 0, 1, 1, 0, 0, 90 * TORADIANS)
  13.     tcGr.Properties("PenColor") = RGB(0, 0, 255)
  14.     
  15.     MsgBox "Graphics count: " & CStr(tcGrs.Count) & " Graphic added to the " & CStr(tcGr.Index)
  16.  
  17. end sub
  18.  
  19. '================= Add graphic the head of collection
  20. Sub AddHead(tcGrs)
  21.  
  22. Dim tcGr
  23.     Set tcGr = tcGrs.AddArcCenterAndPoint(2, 2, 0, 1, 1, 0, -180 * TORADIANS, -90 * TORADIANS)
  24.     tcGr.Properties("PenColor") = RGB(255, 0, 0)
  25.     
  26.     tcGrs.Remove tcGr.Index
  27.  
  28.     tcGrs.AddGraphic tcGr, 0
  29.     MsgBox "Graphics count: " & CStr(tcGrs.Count) & " Graphic added to the " & CStr(tcGr.Index)
  30.  
  31. end sub
  32.  
  33. '================= Add graphic the middle of collection
  34. Sub AddMiddle(tcGrs)
  35. Dim tcGr
  36.     Set tcGr = tcGrs.AddArcCenterAndPoint(1, 0, 0, 1, 1, 0, 90 * TORADIANS, 180 * TORADIANS)
  37.     tcGr.Properties("PenColor") = RGB(0, 255, 0)
  38.     
  39.     tcGrs.Remove tcGr.Index
  40.  
  41.     tcGrs.AddGraphic tcGr, 1
  42.     MsgBox "Graphics count: " & CStr(tcGrs.Count) & " Graphic added to the " & CStr(tcGr.Index)
  43. end sub
  44.  
  45. Sub Main()
  46.  
  47. Dim cnt
  48. Dim tcDwgs
  49. Dim tcDwg
  50. Dim tcGrs
  51.  
  52.     Set tcDwgs = tcApp.Drawings
  53.     cnt = tcDwgs.Count
  54.     MsgBox "Drawings count: " & CStr(cnt)
  55.  
  56.     If (cnt = 0) Then
  57.         Exit Sub
  58.     End If
  59.  
  60.     Set tcDwg = tcApp.ActiveDrawing
  61.     Set tcGrs = tcDwg.Graphics
  62.  
  63.     MsgBox "Graphics count: " & CStr(tcGrs.Count)
  64.  
  65.     AddTail tcGrs
  66.  
  67.     AddHead tcGrs
  68.  
  69.     AddMiddle tcGrs
  70.  
  71.     tcDwg.ActiveView.Refresh
  72. end sub
  73.  
  74.     TORADIANS = 3.14159265358979 / 180
  75.     Set tcApp = CreateObject("TurboCAD.Application")
  76.  
  77.     Main
  78.  
  79.     MsgBox "Done"
  80.